<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="displayMenu">
  <xsl:param name="selectedMenu"/>
  <ul id="menu">
    <xsl:choose>
      <xsl:when test="site[@group='administrator']">
        <xsl:call-template name="menuAdmin"><xsl:with-param name="selectedMenu" select="translate($selectedMenu,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/></xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="menuManager"><xsl:with-param name="selectedMenu" select="translate($selectedMenu,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/></xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </ul>
</xsl:template>

<xsl:template name="menuGeneral">
  <xsl:param name="selectedMenu"/>

  <xsl:if test="$selectedMenu='HOME'"><li class="menuLink"><a class="active" href="index.php?action=homeManager">Home</a></li></xsl:if>
  <xsl:if test="$selectedMenu!='HOME'"><li class="menuLink"><a href="index.php?action=homeManager">Home</a></li></xsl:if>

  <xsl:if test="$selectedMenu='USERS'"><li class="menuLink"><a class="active" href="index.php?action=homeUsers">Users</a></li></xsl:if>
  <xsl:if test="$selectedMenu!='USERS'"><li class="menuLink"><a href="index.php?action=homeUsers">Users</a></li></xsl:if>

  <xsl:if test="$selectedMenu='MAINTENANCE'"><li class="menuLink"><a class="active" href="index.php?action=homeMaintenance">Maintenance</a></li></xsl:if>
  <xsl:if test="$selectedMenu!='MAINTENANCE'"><li class="menuLink"><a href="index.php?action=homeMaintenance">Maintenance</a></li></xsl:if>

  <xsl:if test="$selectedMenu='FORMACL'"><li class="menuLink"><a class="active" href="index.php?action=formACL">Rights</a></li></xsl:if>
  <xsl:if test="$selectedMenu!='FORMACL'"><li class="menuLink"><a href="index.php?action=formACL">Rights</a></li></xsl:if>

</xsl:template>

<xsl:template name="menuManager">
  <xsl:param name="selectedMenu"/>
  <xsl:call-template name="menuGeneral"><xsl:with-param name="selectedMenu" select="$selectedMenu"/></xsl:call-template>
  <!-- You can add a specific menu here by following this template 
  
  <li class="menuLink2 submenuClosed" onmouseover="showMenu(this)" onmouseout="hideMenu(this)">
    <a>Manager</a>
    <ul>
      <li class="submenuLink"><a href="index.php?action=homeManagerPage1">Page 1</a></li>
      <li class="submenuLink"><a href="index.php?action=homeManagerPage2">Page 2</a></li>
    </ul>
  </li>
  -->                                            

</xsl:template>

<xsl:template name="menuAdmin">
  <xsl:param name="selectedMenu"/>
  <xsl:call-template name="menuManager"><xsl:with-param name="selectedMenu" select="$selectedMenu"/></xsl:call-template>

  <li class="menuLink2 submenuClosed" onmouseover="showMenu(this)" onmouseout="hideMenu(this)">
    <xsl:if test="$selectedMenu='ADMIN'"><a class="active">Admin</a></xsl:if>
    <xsl:if test="$selectedMenu!='ADMIN'"><a>Admin</a></xsl:if>
    <ul>
      <li class="submenuLink"><a href="index.php?action=homeMonitoring">Monitoring</a></li>
      <li class="submenuLink"><a href="index.php?action=homeUpdates">Updates</a></li>
      <li class="submenuLink"><a href="index.php?action=homeScaffolding">Scaffolding</a></li>
      <!--<li class="submenuLink"><a href="#">Tables</a></li>-->
      <li class="submenuLink"><a href="index.php?action=formConfig">Config</a></li>
      <li class="submenuLink"><a href="index.php?action=formDispatcher">Dispatcher</a></li>
    </ul>
  </li>
</xsl:template>
</xsl:stylesheet>
